<template>
  <div class="header" :class="!isIndex ? 'box-shadow' : ''">
    <NuxtLink class="left" :to="$i18n.path('m/')">
      <div class="logo"></div>
    </NuxtLink>
    <div class="right">
      <!--广告合作-->
      <NuxtLink :to="$i18n.path(`m/ad/${isEn ? 'en' : 'zh'}`)">
        <div class="news">{{ $t('AD_COOPERATION') }}</div>
      </NuxtLink>
      <!--爆料有奖-->
      <NuxtLink :to="$i18n.path('m/news-disclose')">
        <div class="news">{{ $t('Discover_get_reward') }}</div>
      </NuxtLink>
      <!--切换语言-->
      <template v-if="showLang">
        <NuxtLink
          v-if="$i18n.locale === 'zh'"
          :to="`/km` + $route.fullPath.slice(3)"
          exact
        >
          <div class="lang km-icon"></div>
        </NuxtLink>
        <NuxtLink v-else :to="`/zh` + $route.fullPath.slice(3)" exact>
          <div class="lang zh-icon"></div>
        </NuxtLink>
      </template>
      <!--下载app-->
      <NuxtLink :to="$i18n.path('m/download')">
        <div class="download">{{ $t('Download_APP') }}</div>
      </NuxtLink>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    isIndex: {
      type: Boolean,
      default: false
    },
    showLang: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    isEn() {
      return this.$route.path.includes('km');
    }
  }
};
</script>

<style scoped lang="scss">
* {
  box-sizing: border-box;
}
.header {
  width: 100%;
  height: 88px;
  line-height: 88px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 990;
  background-color: #fff;

  .left {
    .logo {
      width: 104px;
      height: 36px;
      margin: 26px 28px;
      float: left;
      background: url('../../assets/img/logo_text.svg') center no-repeat;
      background-size: contain;
    }
  }

  .right {
    float: right;
    margin-right: 32px;
  }
  .news {
    font-size: 24px;
    line-height: 90px;
    color: rgba(12, 12, 28, 0.7);
    float: left;
    margin-left: 20px;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lang {
    width: 48px;
    height: 48px;
    margin-top: 20px;
    margin-left: 32px;
    float: left;
  }
  .download {
    // width: 152px;
    height: 48px;
    line-height: 51px;
    text-align: center;
    border-radius: 24px;
    background-color: #fa4646;
    color: #fff;
    float: left;
    margin-top: 20px;
    margin-left: 32px;
    font-size: 24px;
    padding: 0 24px;
  }
  .zh-icon {
    background: url('../../assets/img/language_cn.svg') center no-repeat;
    background-size: contain;
  }
  .km-icon {
    background: url('../../assets/img/language_kh.svg') center no-repeat;
    background-size: contain;
  }
}
</style>
